<%-- 
    Document   : index
    Created on : Jul 4, 2013, 6:37:30 PM
    Author     : IK
--%>

<%@page import="javax.naming.InitialContext"%>
<%@page import="java.text.*"%>
<%@page import="edu.capex.ejb.*"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>

<%!    private HelloRemote hel = null;

    public void jspInit() {
        try {
            InitialContext ctx = new InitialContext();
            hel = (HelloRemote) ctx.lookup("java:comp/env/ejb/HelloBean");
        } catch (Exception ex) {
            ex.printStackTrace();
        }

    }

%>

<%
    String result = null, name = null;
    try {
        name = request.getParameter("name");
        if (name != null) {
            result = hel.hello(name);
        }
    } catch (Exception ex) {
        result = "Not valid";
    }
%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Using Stateless Session Bean</title>
    </head>
    <body>
        <h1>Using Stateless session bean</h1><br/><br/>
        <form action="index.jsp" method="POST">
            Enter your name: <input type="text" name="name"><br/>
            <input type="submit" value="Submit"/><br/><br/>
        </form>
        <%
            if (result != null) {
        %><b><%=result%></b><%
            }
        %>
    </body>
</html>
